﻿@page "/iocontrol"
@using BootstrapBlazor.Components
@using TrackSystem.UI.Server.Units


<div class="row g-3">
    <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
        <Button OnClick="@BtnInitSensors" Color="Color.Success">载入传感器</Button>
    </div>
    <div class="col-6 col-sm-4 col-md-3 col-lg-offset-3">
        <Button OnClick="@BtnUnloadSensors" Color="Color.Info">卸载传感器</Button>
    </div>
    <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
        <BootstrapInput TValue="string" Color="Color.Info" @bind-Value="@pageOptions.Filter" />
    </div>
    <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
        <Button> <i class="bi bi-search"></i></Button>
    </div>
</div>

@if (lstPorts is not null && lstPorts.Any())
{
    <Divider></Divider>
    <div class="row g-3">

    @foreach (var port in lstPorts)
    {
        <div class="col-12 col-sm-12 col-lg-6 col-xl-4">
            <ChannelView chn="port" hub="_hubIo" name="@sensorName" SelectedSensor="SelectedSensorChanged"></ChannelView>
        </div>
    }
    </div>
}

<Divider />
<Pagination PageCount="@pageOptions.TotalPages" OnPageLinkClick="@OnPageClick" Alignment="Alignment.Center" />

@if (sensor is not null)
{
    <Divider>传感器 @sensorName </Divider>
    <SensorView snr="sensor" hub="_hubIo" ></SensorView>
}

<Divider></Divider>
<p>@_message</p>
